Skip to content

oidcauth: reduce provider re-initialization in TestOIDCAuthorization_UserinfoPaths#169790

Open
sanchit-CRL wants to merge 1 commit intocockroachdb:masterfrom
sanchit-CRL:worktree-fix-oidc-userinfo-test
Open

oidcauth: reduce provider re-initialization in TestOIDCAuthorization_UserinfoPaths#169790
sanchit-CRL wants to merge 1 commit intocockroachdb:masterfrom
sanchit-CRL:worktree-fix-oidc-userinfo-test

Conversation

@sanchit-CRL
Copy link
Copy Markdown
Collaborator

TestOIDCAuthorization_UserinfoPaths was flaking under race detection because each of 7 test cases created a new httptest.Server and overrode OIDCProviderURL + OIDCRedirectURL cluster settings. Each override triggered reloadConfig() → NewOIDCManager() → HTTP discovery request, producing ~14 provider discovery roundtrips per test run. Under race detection on slow CI machines (s390x), this compounded to 20s+ latency, exceeding the HTTP client timeout.

Restructure the test to share a single mock OIDC provider across the 5 cases that have identical discovery documents (all with a userinfo_endpoint), swapping only the /userinfo response between cases via a mutex-protected variable. Set all cluster settings once before the loop with OIDCEnabled last, so only one provider discovery call occurs during setup. The 2 special cases (absent endpoint, network error) that need different discovery documents run separately with their own mock servers.

This reduces provider discovery HTTP calls from ~14 to 3 and eliminates all settings changes during the main test loop, removing the mutex contention between reloadConfig callbacks and the callback handler that caused the timeouts.

Fixes: #152684

Release note: None

Epic: none

@sanchit-CRL sanchit-CRL requested a review from a team as a code owner May 6, 2026 05:20
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 6, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@cockroach-teamcity cockroach-teamcity added the X-perf-gain Microbenchmarks CI: Added if a performance gain is detected label May 6, 2026
@sanchit-CRL sanchit-CRL force-pushed the worktree-fix-oidc-userinfo-test branch from 7183619 to 4eef28a Compare May 6, 2026 06:22
…UserinfoPaths

TestOIDCAuthorization_UserinfoPaths was flaking under race detection
because each of 7 test cases created a new httptest.Server and
overrode OIDCProviderURL + OIDCRedirectURL cluster settings. Each
override triggered reloadConfig() → NewOIDCManager() → HTTP discovery
request, producing ~14 provider discovery roundtrips per test run.
Under race detection on slow CI machines (s390x), this compounded to
20s+ latency, exceeding the HTTP client timeout.

Restructure the test to share a single mock OIDC provider across the
5 cases that have identical discovery documents (all with a
userinfo_endpoint), swapping only the /userinfo response between
cases via a mutex-protected variable. Set all cluster settings once
before the loop with OIDCEnabled last, so only one provider discovery
call occurs during setup. The 2 special cases (absent endpoint,
network error) that need different discovery documents run separately
with their own mock servers.

This reduces provider discovery HTTP calls from ~14 to 3 and
eliminates all settings changes during the main test loop, removing
the mutex contention between reloadConfig callbacks and the callback
handler that caused the timeouts.

Fixes: cockroachdb#152684

Release note: None

Epic: none

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@sanchit-CRL sanchit-CRL force-pushed the worktree-fix-oidc-userinfo-test branch from 4eef28a to 4d33f09 Compare May 6, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

X-perf-gain Microbenchmarks CI: Added if a performance gain is detected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ccl/oidcccl: TestOIDCAuthorization_UserinfoPaths failed

2 participants